﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="Stock.aspx.cs" Inherits="DevExpressWebApplication1.Module.MM.Stock" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
          <script type="text/javascript">
              function openAdd() {
                  hdfStock.Set("StockId", -1);
                  popupAddEdit.Show();
                  ClearData();
              
              }
              function EditStock() {
                  // var key = gvStock.GetRowKey(gvStock.GetFocusedRowIndex());
                  var index = gvStock.GetFocusedRowIndex();
                  cbAddEdit.PerformCallback('Edit;' + index);
                  popupAddEdit.Show();
              }
              function ClearData() {
                  hdfStock.SetValue('');
                  cbbStockType.SetText('');
              }

    </script>
    <div class="span10">
        <dx:ASPxButton runat="server" ID="btnAdd" Text="Add" Theme="DevEx" UseSubmitBehavior="False" AutoPostBack="False">
            <ClientSideEvents Click="function(s,e){openAdd()}" />
        </dx:ASPxButton>
    </div>
    <div class="span10">
        <dx:ASPxGridView ID="gvStock" ClientInstanceName="gvStock" OnCustomCallback="gvStock_CustomCallback" ClientIDMode="Static"
            Width="100%" runat="server" AutoGenerateColumns="False" DataSourceID="dsStock" KeyFieldName="stock_id" Theme="DevEx">
            <ClientSideEvents RowDblClick="function(s,e){ EditStock() }" />
            <Columns>
                <dx:GridViewDataTextColumn FieldName="stock_id" ReadOnly="True" VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="stock_name" VisibleIndex="1">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="stock_type_id" VisibleIndex="2" Visible="false">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="stock_type_name" VisibleIndex="3">
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" />
        </dx:ASPxGridView>
    </div>
    <asp:SqlDataSource ID="dsStock" runat="server" ConnectionString="<%$ ConnectionStrings:PPL_ERPConnectionString %>" SelectCommand="sp_Stock_Select" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <dx:ASPxPopupControl ID="popupAddEdit" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
        CssPostfix="Aqua" SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" ClientInstanceName="popupAddEdit"
        HeaderText="Quản lý  kho hàng" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Theme="DevEx"
        EnableClientSideAPI="True" Width="650px" Height="200px">
        <%-- PopupElementID="divPotential" --%>
        <ContentCollection>
           <dx:PopupControlContentControl ID="PopupControlContentControl6" runat="server" SupportsDisabledAttribute="True">
                <div style="width: 100%">
                    <dx:ASPxCallbackPanel ID="cbAddEdit" ClientInstanceName="cbAddEdit" OnCallback="cbAddEdit_Callback" runat="server" Width="100%">
                        <PanelCollection>
                            <dx:PanelContent>
                                <dx:ASPxHiddenField ID="hdfStock" ClientInstanceName="hdfStock" runat="server" />
                                <table width="100%">
                                    <tr>
                                        <td style="width: 20%">Kho hàng
                                        </td>
                                        <td style="width: 30%">
                                            <dx:ASPxTextBox ID="txtStock" ClientInstanceName="txtStock" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                        <td style="width: 20%">Loại kho
                                        </td>
                                        <td style="width: 30%">
                                            <dx:ASPxComboBox ID="cbbStockType" runat="server" ClientIDMode="AutoID" DataSourceID="dsStockType"
                                                IncrementalFilteringMode="Contains" LoadingPanelImagePosition="Top" ShowShadow="False"
                                                TextField="stock_type_name" ValueField="stock_type_id" ValueType="System.Int32"
                                                ClientInstanceName="cbbStockType" Width="100%" TabIndex="4" Theme="DevEx">
                                                <ButtonStyle BackColor="Transparent">
                                                    <Paddings Padding="0px" />
                                                    <BackgroundImage ImageUrl="0" />
                                                    <Border BorderStyle="None" />
                                                </ButtonStyle>
                                            </dx:ASPxComboBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                            <dx:ASPxButton ID="ASPxButton1" runat="server" Text="Cập nhật" UseSubmitBehavior="False" AutoPostBack="False">
                                                <ClientSideEvents Click="function(s,e){ gvStock.PerformCallback('Add'); }" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
        <asp:SqlDataSource ID="dsStockType" runat="server" ConnectionString="<%$ ConnectionStrings:PPL_ERPConnectionString %>" SelectCommand="sp_StockType_Select" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
</asp:Content>
